package com.itheima.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.mapper.ClassificationMapper;
import com.itheima.pojo.Classification;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author 林晓伟
 */
@Service
public class ClassificationService {
    @Resource
    private ClassificationMapper classificationMapper;

    /**
     *  H07-新增分类
     */
    public Integer add(Classification classification) {
        return classificationMapper.add(classification);
    }

    /**
     *  根据name判断是否重复
     */
    public Integer judge(String name) {
        return classificationMapper.judge(name);
    }

    /**
     *  H10-编辑分类
     */
    public Integer update(Classification classification) {
        return classificationMapper.update(classification);
    }

    /**
     *  H09-删除分类
     */
    public Integer delete(Integer id) {
        return classificationMapper.delete(id);
    }

    /**
     * H08-分类下拉列表
     */
    public List<Classification> list(String type) {
        return classificationMapper.list(type);
    }

    /**
     *  H08-分类信息分页查询
     */
    public Page<Classification> select(Integer page, Integer pageSize) {
        Page<Classification> page1 = new Page<>(page,pageSize);
        return classificationMapper.selectPage(page1,null);
    }
}
